<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <title>支付</title>
	<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/zepto.js" charset="utf-8"></script>
    <link href="<?php echo TEMPLATE_SITE_URL;?>/css/payment.css" rel="stylesheet" type="text/css">
</head>
<body>

<div id="contentbox" style="min-height: 740px;">

<div class="saleMain">
    <div class="title">拍品信息</div>
    <div class="goodInfo">
        <div class="img" style="background-image: url(<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$output['auction']['auction_add_date'].'/'.$output['auction']['auction_img1'];?>);"></div>
        <div class="desc"><?php echo $output['auction']['auction_description'];?></div>
        <div class="endTime"><span>截止时间：</span><span><?php echo date('Y年m月d日 H:i',$output['auction']['end_time']);?></span></div>
    </div>
    <div class="saleArgs">

        <div class="argItem">
            <span>保证金：</span>
            <span>￥<?php echo $output['auction']['cashprice'];?>元</span>
        </div>
        <!--  
        <div class="argItem">
            <span>运费：</span>
            <span>买家自理</span>
        </div>
        <div class="argItem">
            <span>成交金额：</span>
            <span>￥<?php echo $output['auction_log']['auction_price'];?>元</span>
        </div>-->
    </div>
</div>

<div class="payMain">
    <div class="payPrice">
        <span>保证金：</span>
        <span class="h1">￥<?php echo $output['auction']['cashprice'];?>元</span>
        <span class="payMemo"></span>
    </div>
    <div class="payMethodList">
    	<!-- 开通 needOpen  -->
    	<?php 
    		
    		if($output['user']['price']>=$output['auction']['cashprice']){ 
				$b_selected = 'selected';
				$paymentname = 'balance';
			}else{
				$w_selected = 'selected';
				$paymentname = 'weixin';
			}
    	?>
        <div class="payMethod balance <?php echo $b_selected;?>" pn="balance">
            <div class="checkbox"></div>
            <div class="icon"></div>
            <div class="content">
                <div class="title">余额支付</div>
                <div class="desc">可用余额：￥ <?php echo $output['user']['price'];?> 元</div>
            </div>
            <div class="open">
            <?php if(empty($output['user']['paypasswd'])){?>
            <a href="index.php?act=payment&op=kaitong&user_id=<?php echo $output['user']['user_id'];?>">开通</a>
            <?php }else{?>
            <a href="index.php?act=payment&op=recharge">充值</a>
            <?php }?>            
            </div>
        </div>
        <div class="payMethod weixin <?php echo $w_selected;?>" pn="weixin">
            <div class="checkbox"></div>
            <div class="icon"></div>
            <div class="content">
                <div class="title">微信支付</div>
                <div class="desc">使用微信支付，简单方便</div>
            </div>
        </div>
    </div>
    <p><font color="red" id="error_tip" style="padding-left:20px;"></font></p>
    <div class="payBtn">
    	<input type="hidden" name="paymentname" value="<?php echo $paymentname;?>">
        <div class="submit">安全支付</div>
    </div>
</div>
</div>
<script type="text/javascript">
$(function(){
	$('.payMethod').click(function(){
		$('.payMethod').removeClass('selected');
		$(this).addClass('selected');
		$('input[name=paymentname]').val($(this).attr('pn'));
	});

	$('.submit').click(function(){
		var auction_price = '<?php echo $_GET['auction_price']?>';
		var user_id = '<?php echo $output['user']['user_id']?>';
		var auction_id = '<?php echo $output['auction']['id']?>';
		var paymentname = $('input[name=paymentname]').val();
		var cashprice = parseInt('<?php echo $output['auction']['cashprice']?>');
		
		if(paymentname=='weixin'){
			location.href = 'index.php?act=payment&op=cash&auction_id='+auction_id+'&auction_price='+auction_price;
			return false;
		}
		
		var user_price = parseInt('<?php echo $output['user']['price'];?>');

		if(user_price<cashprice){
			$('#error_tip').html('余额不足，请充值');
			return false;
		}
		
		$.ajax({
			type:'post',
			url:'index.php?act=payment&op=paymentcash',
			data:{auction_price:auction_price,user_id:user_id,auction_id:auction_id,paymentname:paymentname},
			dataType:'json',
			success:function(data){
				if(data.state){
					location.href = 'index.php?act=payment&op=balancepaymentcash&auction_id='+auction_id+'&auction_price='+auction_price;
					return false;
				}else{
					$('#error_tip').html('余额不足，请充值');
					return false;
				}
			}
		});
	});
	
});
</script>
</body>
</html>